package com.itheima.mall.web.pms;


import com.itheima.mall.pojo.pms.SkuStock;
import com.itheima.mall.service.pms.SkuStockService;
import com.itheima.mall.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/sku")
public class SkuStockController {
    @Autowired
    private SkuStockService skuStockService;

    //批量更新sku库存信息
    @PostMapping("update/{pid}")
    public R updateSku(@PathVariable("pid") Integer pid,@RequestBody SkuStock skuStock){
        skuStockService.updateSku(pid,skuStock);
        return R.succeed(null,"更新成功");
    }

    //根据商品ID及sku编码模糊搜索sku库存
    @GetMapping("{pid}")
    public R selectID(@PathVariable Integer pid,String keyword){
        List<SkuStock>skuStock =skuStockService.selectID(pid,keyword);
        return R.succeed(skuStock,"查询成功");
    }
}
